package com.hxzy.controller.storetype;

import com.alibaba.fastjson.JSONObject;
import com.hxzy.util.ThreadLocalUtil;
import com.hxzy.common.BaseServlet;
import com.hxzy.dto.StoreTypeDTO;
import com.hxzy.entity.StoreType;
import com.hxzy.service.StoreTypeServie;
import com.hxzy.service.impl.StoreTypeServieImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Description:
 * @Author: ykj
 * @Date: 2022/3/8 21:56
 */
@WebServlet(urlPatterns = "/storetype")
public class StoretypeServlet extends BaseServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        System.out.println(ThreadLocalUtil.threadLocal.get());
        //分页
        super.startPage(req);
        try {
            StoreTypeDTO storeTypeDTO = super.CollectiongParameterToJSON(req, StoreTypeDTO.class);
            StoreTypeServie servie=new StoreTypeServieImpl();
            List<StoreType> search = servie.search(storeTypeDTO);
            super.render(resp, JSONObject.toJSONString(search));

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
